<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
		<meta name="description" content="">
		<meta name="author" content="">

		<title>后台</title>

		<link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

		<!-- Bootstrap core CSS -->
		<link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
		<link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
		<link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />

	</head>

	<body>

		<include file="Common/topNav" />

		<div class="container-fluid">
			<div class="row">
				<include file="Common/leftMenu" />
				<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
					<div class="cont-title clearfix">
						<div class="title">区域统计信息</div>
					</div>
					<form class="jc-search form-inline" action="{:U('Admin/Index/index')}" method="post" id="searchForm">
						<div class="form-group">
							<label>商圈:</label>
							<select class="form-control" name="trade_id">
								<option value="" <if condition="$trade_id eq ''">selected</if>>全部</option>
								<foreach name="tradeList" item="trade">
									<option value="{$trade.id}" <if condition="$trade.id eq $trade_id">selected</if>>{$trade.name}</option>
								</foreach>
							</select>
						</div>
                                                <div class="form-group">
							<label>街道:</label>
							<select class="form-control" name="orgId">
                                                            <option value="">全部</option>
                                                            <volist name="orgList" id="ol">
                                                                <option value="{$ol.id}" <if condition="$ol['id'] eq $orgId"> selected="selected"</if>>{$ol.name}</option>
                                                            </volist>
								
							</select>
						</div>

						<div class="form-group">
							<label>楼宇:</label>
							<select class="form-control" name="houseId">
								<option value="">全部</option>

							</select>
						</div>
						<div class="form-group">
							<label>年份:</label>
							<select class="form-control" name="year">
								<option value="2018" <if condition="$year eq '2018'">selected</if>>2018年</option>
								<option value="2017" <if condition="$year eq '2017'">selected</if>>2017年</option>
								<option value="2016" <if condition="$year eq '2016'">selected</if>>2016年</option>
								<option value="2015" <if condition="$year eq '2015'">selected</if>>2015年</option>
								<option value="2014" <if condition="$year eq '2014'">selected</if>>2014年</option>
								<option value="2013" <if condition="$year eq '2013'">selected</if>>2013年</option>
								<option value="2012" <if condition="$year eq '2012'">selected</if>>2012年</option>

							</select>
						</div>
						<input class="btn" type="button" value="搜索" onclick="init()" />
					</form>
					<div class="table-responsive main-box row">
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    		<div class="main-item">
								<h3 class="tit">总体统计<i class="icon"></i></h3>
								<div class="info-box clearfix">
									<div class="info-item">
										<div class="info-btn info-btn5">
											<div class="content">
												<h3 class="title">楼宇数量</h3>
												<p class="num" id="houseNumber">{$generalStatistics.houseNumber}个</p>
											</div>
										</div>
									</div>
									<div class="info-item">
										<div class="info-btn info-btn6">
											<div class="content">
												<h3 class="title">企业数量</h3>
												<p class="num" id="companyNumber">{$generalStatistics.companyNumber|number_format}个</p>
											</div>
										</div>
			                        </div>
			                        <div class="info-item">
			                        	<div class="info-btn info-btn7">
			                        		<div class="content">
				                        		<h3 class="title">营业总额</h3>
				                        		<p class="num" id="turnoverSum">{$generalStatistics.turnoverSum|number_format}万元</p>
			                        		</div>
			                        	</div>
			                        </div>
			                        <div class="info-item">
			                        	<div class="info-btn info-btn8">
			                        		<div class="content">
				                        		<h3 class="title">税收总额</h3>
				                        		<p class="num" id="taxAmountSum">{$generalStatistics.taxAmountSum|number_format}万元</p>
			                        		</div>
			                        	</div>
			                        </div>
								</div>
							</div> 
	                    </div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<div class="main-item">
								<h3 class="tit">楼宇业态分布<i class="icon"></i></h3>
								<div id="ytfb" class="cont"></div>
							</div>
						</div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<div class="main-item">
								<h3 class="tit">楼宇纳税排名<i class="icon"></i>
									<select name="amount_type" style="float: right;margin-top: -5px;">
                                                                            <option value="0">亿元以上</option>
                                                                            <option value="5000">亿元以下</option>
                                                                        </select>
								</h3>
								<div id="nspm" class="cont">
									<table class="main-table">
										<thead>
											<tr>
												<th>排名</th>
												<th>楼宇名称</th>
												<th>营业收入（万元）</th>
												<th>纳税额（万元）</th>
											</tr>
										</thead>
										<tbody id="nspmList">
                                                                                <volist name="nspm" id="nm">
                                                                                    <tr>
                                                                                        <td class="no1">{$key+1}</td>
                                                                                        <td>{$nm.name}</td>
                                                                                        <td>{$nm.turnover|number_format=2}</td>
                                                                                        <td class="red">{$nm.tax_amount|number_format=2}</td>
                                                                                    </tr>
                                                                                </volist>
										</tbody>
									</table>
								</div>
							</div>
						</div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<div class="main-item">
								<h3 class="tit">企业纳税占比情况<i class="icon"></i></h3>
								<div id="nszb" class="cont"></div>
							</div>
						</div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<div class="main-item">
								<h3 class="tit">企业纳税金额情况<i class="icon"></i></h3>
								<div id="nsje" class="cont"></div>
							</div>
						</div>
                                            
                                           
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
							<div class="main-item">
								<h3 class="tit">楼宇经济运行态势<i class="icon"></i></h3>
								<div id="yxts" class="cont"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/echarts/echarts.min.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/echarts/macarons.js"></script>
		<script type="text/javascript">
			var houseId = "{$houseId}";
			$(function() {
				houseList();
                init();
                $("select[name='orgId']").change(houseList);
                $("select[name='amount_type']").change(nspm);
            });
                        
			function houseList(){
				$.ajax({
					url:"{:U('Admin/Index/asyncHouseList')}",
					type:"post",
					dataType:"json",
					data:{
						orgId : $("select[name='orgId']").val() || 0 
					},
					success:function(data){
						var html = '<option value="">全部</option>';
						for(var i = 0 ; i < data.list.length ; i++){
							var item = data.list[i];
							var selected = '';
							if(item.id == houseId){
								selected = 'selected="selected"';
							}
							html += '<option value="'+item.id+'" '+selected+'>'+item.name+'</option>';
						}
						$("select[name='houseId']").html(html);
					}
				})
			}

			function init() {
				ytfb();
				nspm();
				nszb();
				nsje();
				yxts();
                                getGeneralStatistics();
			}
                        
                        function getGeneralStatistics(){
                            
                            common.ajax("{:U('Admin/Index/getGeneralStatistics')}",$("#searchForm").serialize(),function (data) {
                                $("#houseNumber").html(data.houseNumber+"个");
                                $("#companyNumber").html(data.companyNumber+"个");
                                $("#turnoverSum").html(data.turnoverSum+"万元");
                                $("#taxAmountSum").html(data.taxAmountSum+"万元");
                                
                            });
                        }
			
			function nspm() {
                            var data = $("#searchForm").serialize();
                            var amount_type = $("select[name='amount_type']").val();
                common.ajax("{:U('Admin/Index/getNspm')}",data+"&amount_type="+amount_type,function (nspmData) {
                    var html = '';
                    if(nspmData.length == 0) {
                        html = '<tr><td colspan="4">暂无数据</td></tr>';
                        $("#nspmList").html(html);
                        return;
					}
					$.each(nspmData,function (index,item) {
                        html += '<tr>';
                        html += '<td class="no1">'+(index+1)+'</td>';
                        html += '<td>'+item.name+'</td>';
                        html += '<td>'+common.formatNumber(item.turnover,2)+'</td>';
                        html += '<td class="red">'+common.formatNumber(item.tax_amount,2)+'</td>';
                        html += '</tr>';
                    });
                    $("#nspmList").html(html);
                });
            }

			function yxts() {
                var myChart = echarts.init(document.getElementById('yxts'), "macarons");
                myChart.showLoading({text:"正在加载，请稍后...",color:"#7EC0EE"});
			    common.ajax("{:U('Admin/Index/getYxts')}",$("#searchForm").serialize(),function (yxtsData) {
                    var len = yxtsData.series[0].data.length;
                    $.each(yxtsData.series[0].data,function (index,item) {
                        if (parseFloat(item) <= 0) {
                            len--;
                        }
                    });
                    if (len == 0) {
                        $("#yxts").removeAttr("_echarts_instance_");
                        $("#yxts").html('<p style="padding-top:30px;text-align: center;">暂无数据</p>');
                        return;
                    }
                    myChart.hideLoading();
                    myChart.setOption(yxtsData);
                });
			}

			function nsje() {
                var myChart = echarts.init(document.getElementById('nsje'), "macarons");
                myChart.showLoading({text:"正在加载，请稍后...",color:"#7EC0EE"});
                common.ajax("{:U('Admin/Index/getNsje')}",$("#searchForm").serialize(),function (nsjeData) {
                    var len = nsjeData.series[0].data.length;
                    $.each(nsjeData.series[0].data,function (index,item) {
						if (!item) {
						    len--;
						}
                    });
                    if (len == 0) {
                        $("#nsje").removeAttr("_echarts_instance_");
                        $("#nsje").html('<p style="padding-top:30px;text-align: center;">暂无数据</p>');
                        return;
                    }
                    myChart.hideLoading();
                    myChart.setOption(nsjeData);
                });
			}

			function nszb() {
                var myChart = echarts.init(document.getElementById('nszb'), "macarons");
                myChart.showLoading({text:"正在加载，请稍后...",color:"#7EC0EE"});
                common.ajax("{:U('Admin/Index/getNszb')}",$("#searchForm").serialize(),function (nszbData) {
                    var len = nszbData.series[0].data.length;
                    $.each(nszbData.series[0].data,function (index,item) {
                        if (!item.value) {
                            len--;
                        }
                    });
                    if (len == 0) {
                        $("#nszb").removeAttr("_echarts_instance_");
                        $("#nszb").html('<p style="padding-top:30px;text-align: center;">暂无数据</p>');
                        return;
                    }
                    myChart.hideLoading();
                    myChart.setOption(nszbData);
                });
			}

			function ytfb() {
                var myChart = echarts.init(document.getElementById('ytfb'), "macarons");
                myChart.showLoading({text:"正在加载，请稍后...",color:"#7EC0EE"});
                common.ajax("{:U('Admin/Index/getYtfb')}",$("#searchForm").serialize(),function (ytfbData) {
                    var len = ytfbData.series[0].data.length;
                    $.each(ytfbData.series[0].data,function (index,item) {
                        if (!item.value) {
                            len--;
                        }
                    });
                    if (len == 0) {
                        $("#ytfb").removeAttr("_echarts_instance_");
                        $("#ytfb").html('<p style="padding-top:30px;text-align: center;">暂无数据</p>');
                        return;
                    }
                    ytfbData.series[0].center = ['60%', '50%'];
                    myChart.hideLoading();
                    myChart.setOption(ytfbData);
                });
			}
		</script>
	</body>

</html>